<?php
namespace User\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $this->login();
    }

    public function login(){
        if(session('?username')){
            $this->redirect('/Home/Index');
        }else{
            $title = M('settings')->where(array('name'=>'title'))->find();
            $description = M('settings')->where(array('name'=>'description'))->find();
    
            $this->assign('title', $title['value']);
            $this->assign('description', $description['value']);
            $this->display('login');
        }
    }

    public function repass(){
        if(session('?username')){
            $this->display('repass');
        }else{
            $this->redirect('/User/Index/login');
        }
    }

    public function logout(){
        session(null);
        $this->redirect('/User/Index/login');
    }
}